package chat;

import test.ProxyTest;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
public class Test2 {
    public static void main(String[] args) {
        int i=9;
        switch (i) {
            default:
                System.out.println("default");
            case 0:
                System.out.println("zero");
                break;
            case 1:
                System.out.println("one");
                break;
            case 2:
                System.out.println("two");
                break;
        }
    }

    public static int Count(String  fileName , String str) throws Exception{
        //获取文件中的字符
        FileReader fr = new FileReader(new File(fileName));
        BufferedReader br = new BufferedReader(fr);
        StringBuffer ss = new StringBuffer();
        String line;
        while((line = br.readLine()) != null ){
            ss.append(line);
        }
        String filestr = ss.toString();  //文件中的字符
        System.out.println(filestr);
        //统计这个字符串在这个文件中出现的次数

        int num = 0;
        while(filestr.length() > str.length()){
            int index  = filestr.indexOf(str);
            if(index>-1){             //存在字符串str
                num++;
                filestr = filestr.substring(index+str.length());
            }
            else{
                break;
            }

        }
        return num;
    }
}
